# @algorithm @lc id=2124 lang=python3 weekname=weekly-contest-257
# @title first-day-where-you-have-been-in-all-the-rooms


from cn.Python3.mod.preImport import *
# @test([0,0])=2
# @test([0,0,2])=6
# @test([0,1,2,0])=6
class Solution:
    def firstDayBeenInAllRooms(self, nextVisit: List[int]) -> int: